//
//  home_bottomTableViewCell.m
//  sellHouse
//
//  Created by 李 佳伟 on 2018/11/23.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "home_bottomTableViewCell.h"
#import "JTCSM.h"
#import "InvestorsModel.h"

@interface home_bottomTableViewCell ()
{
    UILabel *secondtitleLabel;
    NSArray *jigouList;
}

@end

@implementation home_bottomTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        
        
        
    }
    
    return self;
}

- (void)setValueWithInvestoursModel:(NSMutableArray *)investorsModelList hezuoModle:(NSMutableArray *)hezuoModleList{
    if (investorsModelList.count <= 0 && hezuoModleList.count <=0) {
        return;
    }
    
    if (jigouList!=nil) {
        for (int i = 0 ; i<jigouList.count; i++) {
            UIView *view = [self.contentView viewWithTag:4000+i];
            for (UIView *subview in [view subviews]) {
                [subview removeFromSuperview];
            }
        }
    }
    
    for (UIView *view in [self.contentView subviews]) {
        if (view.tag !=100 && view.tag !=101) {
            [view removeFromSuperview];
        }
    }
    for (UIView *view in [self.contentView subviews]) {
        [view removeFromSuperview];
    }
    
    UIView *twolineviw = [df lineViewWithHeightofTop:10 superView:self.contentView lineHeight:10 space:0];
    secondtitleLabel = [UILabel initWithFrame:CGRectMake(Kspace, KVIEW_Y(twolineviw), KSCREENWidth-2*Kspace, 48) text:@"投资机构" font:17 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(51, 51, 51, 1) backgroundColor:nil];
    twolineviw.tag = 100;
    secondtitleLabel.tag = 101;
    [self.contentView addSubview:secondtitleLabel];
    [df lineViewWithHeightofTop:KVIEW_Y(secondtitleLabel) superView:self.contentView lineHeight:1 space:Kspace];
    
    CGFloat twochangespace = 8;
    CGFloat youshiviewwidth = (KSCREENWidth-2*Kspace-twochangespace)/2;
    CGFloat labeltitleHeight = 20;
    CGFloat youshiviewHeihgt = youshiviewwidth/5*3+labeltitleHeight+5;
    
    
    jigouList = investorsModelList;
    
    for (int i = 0 ; i<investorsModelList.count; i++) {
        
        InvestorsModel *model = investorsModelList[i];
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(Kspace +(youshiviewwidth+twochangespace)*(i%2), KVIEW_Y(secondtitleLabel)+22+(youshiviewHeihgt+twochangespace)*(i/2), youshiviewwidth, youshiviewHeihgt)];
        [self.contentView addSubview:view];
        view.tag = 4000+i;
        UIImageView *imagev = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, youshiviewwidth, youshiviewHeihgt-labeltitleHeight)];
        [imagev sd_setImageWithURL:KImageUrl(model.url) placeholderImage:[UIImage imageNamed:[NSString stringWithFormat:@"tzi%d.jpeg",i]]];
        [view addSubview: imagev];
        [df layerWithView:imagev radius:0 width:1 color:RGBACOLOR(241, 241, 241, 1)];
        UILabel *titlel = [UILabel initWithFrame:CGRectMake(0, KVIEW_Y(imagev)+5, youshiviewwidth, labeltitleHeight) text:model.name font:14 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(102, 102, 102, 1) backgroundColor:nil];
        [view addSubview:titlel];
        
    }
    UIView *tagview = [self.contentView viewWithTag:4003];
    UIView *threeLine= [df lineViewWithHeightofTop:KVIEW_Y(tagview)+23 superView:self.contentView lineHeight:10 space:0];
    
    UILabel *thirdtitleLabel = [UILabel initWithFrame:CGRectMake(Kspace, KVIEW_Y(threeLine), KSCREENWidth-2*Kspace, 48) text:@"合作伙伴" font:17 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(51, 51, 51, 1) backgroundColor:nil];
    [self.contentView addSubview:thirdtitleLabel];
    [df lineViewWithHeightofTop:KVIEW_Y(thirdtitleLabel) superView:self.contentView lineHeight:1 space:Kspace];
    
    
    CGFloat my_youshiviewwidth = (KSCREENWidth-4*Kspace)/3;
    NSInteger num = hezuoModleList.count;
    for (int i = 0 ; i<num; i++) {
        
        UIImageView *view = [[UIImageView alloc]initWithFrame:CGRectMake(Kspace +(my_youshiviewwidth+Kspace)*(i%3), KVIEW_Y(thirdtitleLabel)+22+(my_youshiviewwidth/375*171+twochangespace)*(i/3), my_youshiviewwidth, my_youshiviewwidth/375*171)];
        NSString *iamgeurl = [NSString stringWithFormat:@"%@",hezuoModleList[i]];
        [view sd_setImageWithURL:KImageUrl(iamgeurl) placeholderImage:[UIImage imageNamed:[NSString stringWithFormat:@"huo%d.jpg",i+1]]];
        [self.contentView addSubview:view];
        [df layerWithView:view radius:0 width:1 color:RGBACOLOR(241, 241, 241, 1)];
        view.tag = 5000+i;
    }
    UIView *bottomview = [self.contentView viewWithTag:5000+num-1];
    [df lineViewWithHeightofTop:KVIEW_Y(bottomview)+23 superView:self.contentView lineHeight:10 space:0];
}

@end
